﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;

public partial class rxt_rxtCpgl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bd();
        }
    }
    protected void Bd()
    {
        CpglBLL bll = new CpglBLL();
        GridView1.DataSource = bll.GetTop50();
        GridView1.DataBind();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "cupdate")
        {
            Response.Redirect("cpgl_Edit.aspx?id=" + e.CommandArgument.ToString());
        }
        else if (e.CommandName == "cdelete")
        {
            CpglBLL bll = new CpglBLL();
            if (bll.Delete(int.Parse(e.CommandArgument.ToString())))
            {
                ClientScript.RegisterStartupScript(GetType(), "key", "alert('删除成功');document.location='rxtCpgl.aspx'", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "key", "alert('删除失败')", true);
            }
        }

    }
}
